﻿using System;
using System.Collections.Generic;
using System.Linq;
using Infrastucture;

namespace TimeSplicerModule.DomainModels
{
    public class ProjectRolePermissionModel : DomainObject
    {
        private Guid _projectRolePermissionGuid;
        private Guid _projectRoleGuid;
        private Guid _applicationPermissionGuid;
        private ProjectRoleModel _role;
        private ApplicationPermissionModel _permission;
        private List<ApplicationPermissionModel> _applicationPermissions;


        public Guid ProjectRolePermissionGuid
        {
            get { return _projectRolePermissionGuid; }
            set { SetProperty(ref _projectRolePermissionGuid, value); }
        }
        public Guid ProjectRoleGuid
        {
            get { return _projectRoleGuid; }
            set { SetProperty(ref _projectRoleGuid, value); }
        }
        public Guid ApplicationPermissionGuid
        {
            get { return _applicationPermissionGuid; }
            set
            {
                SetProperty(ref _applicationPermissionGuid, value);

                if (this.ApplicationPermissions != null)
                    this.Permission = this.ApplicationPermissions.FirstOrDefault(x => x.ApplicationPermissionGuid == this.ApplicationPermissionGuid);
            }
        }
        public ProjectRoleModel Role
        {
            get { return _role; }
            set { SetProperty(ref _role, value); }
        }
        public ApplicationPermissionModel Permission
        {
            get { return _permission; }
            set { SetProperty(ref _permission, value); }
        }
        public List<ApplicationPermissionModel> ApplicationPermissions
        {
            get { return _applicationPermissions; }
            set { SetProperty(ref _applicationPermissions, value); }
        }
    }
}
